# 8-1 定义函数，调用函数

def display_message():
    print('颤抖吧函数，我来学你了哈哈哈哈！')

display_message()

# 8-2 喜欢的图书

def favorite_book(book):
    print(book+'这本书老好了，振聋发聩醍醐灌顶恍然大悟重新做人。')

favorite_book('道德经')

# 8-3 打印衬衫
def make_shirt(word,size):
    if size =='X':
        print(word)
        print('一起啃书')

    if size =='M':
        print(' -----_____----- ')
        print('|               |')
        print(' ---         ---')
        print('   |'+word+' !|   ')
        print('   |  一起啃书|   ')
        print('   |   ❥(^_-)|   ')
        print('    ---------    ')

    if size=='L':
        print(word)
        print('一起啃书')

make_shirt('奋发图强','X')
make_shirt(size='M',word='誓死不屈')

# 8-4

def make_shirt(size,word='我爱拍桑'):
    if size =='X':
        print(word)
        print('一起啃书')

    if size =='M':
        print(' -----_____----- ')
        print('|               |')
        print(' ---         ---')
        print('   |'+word+' !|   ')
        print('   |  一起啃书|   ')
        print('   |   ❥(^_-)|   ')
        print('    ---------    ')

    if size=='L':
        print(word)
        print('一起啃书')

make_shirt('M')
make_shirt('M','冲鸭冲鸭')

# 8-5
def describe_city(city,country='China'):
    print(city+'在'+country+'.')
describe_city('Hangzhou')
describe_city('zhuhai')
describe_city('gongzhufen')
describe_city('wangchuan','广莫之野无何有之乡')

# 8-6 返回值

def describe_city(city,country='China'):
    city_country=city+','+country
    return city_country

city_country_liaoning=describe_city('Liaoning')

print(city_country_liaoning)

# 8-7 返回字典

def make_album(singer,special_edition):
    music={}
    music['singer']=singer
    music['special_edition']=special_edition
    print(music)

make_album('周杰伦','依然范特西')
make_album('周杰伦','摩羯座')
make_album('致敬大神','一起啃书')

# 8-8 while

def make_album(singer,special_edition):
    music={}
    music['singer']=singer
    music['special_edition']=special_edition
    print(music)

print("输入你喜欢的歌手和专辑，输入't'随时退出")
while True:
    singer=input('你喜欢的歌手是谁？')
    if singer=='t':
        break
    else:
        special_edition=input('他有什么专辑？')
        if special_edition=='t':
            break
        else:
            make_album(singer,special_edition)

# 8-9 函数，功能是打印列表

def print_book_list(book_list):
    for book in book_list:
        print(book)

python_book_list=['Python编程从入门到实践','Python基础教程','Python语言及其应用']
print_book_list(python_book_list)

# 8-10 利用函数，对列表进行修改

def print_book_list(book_list):
    """打印列表"""
    for book in book_list:
        print(book)

def change_book_list(book_list):
    """修改列表"""
    n=0
    while n<len(book_list):
        book_list[n]='推荐：'+book_list[n]
        n+=1
    print_book_list(book_list)


python_book_list=['Python编程从入门到实践','Python基础教程','Python语言及其应用']

change_book_list(python_book_list)

# 8-11

def print_book_list(book_list):
    """打印列表"""
    for book in book_list:
        print(book)

def change_book_list(book_list):
    """修改列表"""
    n=0
    while n<len(book_list):
        book_list[n]='推荐：'+book_list[n]
        n+=1
    print_book_list(book_list)


python_book_list=['Python编程从入门到实践','Python基础教程','Python语言及其应用']

change_book_list(python_book_list[:])
print_book_list(python_book_list)


# 8-12 输入任意数量实参 三明治里加什么


def sandwich(*foods):
    print('您的要的三明治：')
    for food in foods:
        print('-'+food)

sandwich('guojiang','naiyou','huotui')

# 8-13

def build_profile(first, last, **user_info):
    profile={}
    profile['first_name']=first
    profile['last_name']=last
    for key, value in user_info.items():
        profile[key]=value
    return profile
wo=build_profile('zhijing','dashen',tezheng='mei',aihao='zhaojingzi')
print(wo)

# 8-14 自己定义一个字典 照上面抄就可以了

def cars(brand,type,**info):
    vehicle={}
    vehicle['牌子']=brand
    vehicle['型号']=type
    for key, value in info.items():
        vehicle[key]=value
    return vehicle

che=cars('aima','diandongche',daiyan='zhoujielun',yanse='fen')
print(che)

# 8-15 实现的功能就是函数导入 8.4.1的函数，


import sys
sys.path.append("D:\Python练习")

from printing_function import *

unprinted_designs=['iphone case','robot pendant','dodecahedron']
completed_models=[]

# printing_function.print_models(unprinted_designs[:],completed_models)
# printing_function.show_completed_models(unprinted_designs)
# printing_function.show_completed_models(completed_models)


print_models(unprinted_designs[:],completed_models)
show_completed_models(unprinted_designs)
show_completed_models(completed_models)



# 至 8-17


